<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>继承</title>
</head>

<body>

</body>

</html>
<script>
    // Father.prototype.lastName = 'Deng';
    // function Father(){}
    // function Son(){}
    // // Son.prototype = Father.prototype;

    // // let son = new Son();
    // let father = new Father();

    // 实现继承封装方法
    // function inherit (Target, Origin){
    //     Target.prototype = Origin.prototype;
    // }
    // Father.prototype.lastName = 'Deng';
    // function Father(){}
    // function Son(){}
    // inherit(Son,Father);
    // let son = new Son ();



    // 圣杯模式继承
    /* 
    Father.prototype
    function F(){}
    F.prototype = Father.prototype()
    Son.prototype = mew F()
     */

    function inherit(Target, Origin) {
        function F() {};
        F.prototype = Origin.prototype;
        Target.prototype = new F();
        Target.prototype.constuctor = Target;
        Target.prototype.uber = Origin.prototype;
    }
    Father.prototype.lastName = 'Deng';

    function Father() {}

    function Son() {}
    inherit(Son, Father);
    let son = new Son();


    let inherit = (function () {
        let F = function () {};
        return function (Target, Origin) {
            F.prototype = Origin.prototype;
            Target.prototype = new F();
            Target.prototype.constuctor = Target;
            Target.prototype.uber = Origin.prototype;
        }
    }())



    // 命名空间 闭包的运用
    var init = (function (){
        let name = 'ac';
        function callName(){
            console.log(name);
        }
        return function (){
            callName();
        }
    }())

    // 入口函数命名前加init

</script>